/**
 * https://github.com/openssl/openssl.git
 */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef pkcs1oaep_h
#define pkcs1oaep_h
#include <stdio.h>

typedef void (*HashAlgo)(const void *data, size_t dataLen, void *buf, int bufLen);
typedef void (*MGFunc)(const char *seed, size_t seedLen, char *maskedBuf, size_t maskLen, HashAlgo hashAlgo, size_t hLen);
typedef void (*RandFunc)(char *buf, size_t bufLen);
typedef void (*Encrypt)(char *em, char *key, size_t keyLen, char *buf, size_t *bufLen);

void mgf1(const char *seed, size_t seedLen, char *maskedBuf, size_t maskLen, HashAlgo hashAlgo, size_t hLen);

// 0 for ok, -1 for error
int8_t pkcs1oaepEncode(size_t keyLen,
		       const char *data,
		       size_t dataLen,
		       char *em,
		       HashAlgo hashAlgo,
		       int hashLen,
		       MGFunc mgfunc,
		       HashAlgo mgfHashAlgo,
		       int mgfHashLen,
		       RandFunc randFunc,
		       char *label,
		       size_t labelLen);

// 0 for ok, -1 for error
int8_t pkcs1oaepDecode(size_t keyLen,
               char *em,
		       char *data,
		       size_t *dataLen,
		       HashAlgo hashAlgo,
		       int hashLen,
		       MGFunc mgfunc,
		       HashAlgo mgfHashAlgo,
		       int mgfHashLen,
		       char *label,
		       size_t labelLen);

#endif /* pkcs1oaep_h */

#ifdef __cplusplus
}
#endif